import React from 'react';
import './index.less';
import {connect} from "dva";
import Curd from "components/Curd";
import createColumns from "./columns";
import searchColumns from "./searchColumns";
import BaseComponent from "components/Base/BaseComponent";
import {Layout, Modal} from "antd";
import SellerEmployee from "../../SellerEmployee/components";
const {Content, Footer, Header} = Layout;


@connect(({seller}) => ({seller}))
export default class extends BaseComponent {

  state = {
    visible: false,
    sellerId: undefined,
  }


  getNamespace() {
    return 'seller';
  }

  showSellerEmployee = (sellerId) =>{
    this.setState({sellerId, visible: true});
  }

  handleCancel = () => {
    this.setState({visible: false});
  }

  render() {

    const {visible, sellerId} = this.state;

    const curdProps = {
      ...this.props,
      align: 'center',
      namespace: 'seller',
      tableColumns: createColumns,
      searchColumns: searchColumns,
      showSellerEmployee: this.showSellerEmployee,
    };


    return (
      <Layout>
        {
          <Content>
            <Curd {...curdProps}/>
            <Modal
              width={800}
              title={"商家员工列表"}
              visible={visible}
              onCancel={this.handleCancel}
              footer={null}
            >
              {
                <SellerEmployee sellerId={sellerId}/>
              }
            </Modal>
          </Content>
        }
      </Layout>
    );

  }

}
